package cn.test.my.excel.poi.convert;

import java.lang.reflect.Field;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import cn.test.my.excel.poi.annotation.SetCellStyle;


/**
 * LocalDateTime 转换
 *
 * @author summit
 * @since 2021/6/6 20:07
 */
public class LocalDateTimeConverter implements Converter<LocalDateTime> {

	@Override
	public Class<LocalDateTime> supportJavaTypeKey() {
		return LocalDateTime.class;
	}

	@Override
	public LocalDateTime convertToJavaData(Field filed, String rowData, SetCellStyle style)
			throws Exception {
		String pattern = style.datePattern();

		return LocalDateTime.parse(rowData, DateTimeFormatter.ofPattern(pattern));
	}
}
